package cn.stacey.spring.ssm.web;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController {
Logger logger = LoggerFactory.getLogger(LoginController.class);
	@RequestMapping("/pages/login")
	public String login(@RequestParam("user") String user,
			@RequestParam("password") String password, HttpSession session) {
		if("admin".equals(user)) {
			session.setAttribute("user", user);
			logger.debug("登录成功");
			//跳到文章列表
			return "forward:/pages/list";
		}else {
			//重新跳到登录界面
		return "login";
		}
		
	}
}
